#include "Widget.h"
#include "ui_Widget.h"
#include <QSettings>
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    ui->pushButton->setText(tr("这是一个tr设置文本按钮"));
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_radioButton_Chinese_clicked(bool checked)
{
    if(checked)
    {
        bool ok = qApp->removeTranslator(trans);
        qInfo()<<"是否移除成功"<<ok;
        delete trans ;
        trans=new QTranslator;
        ok = trans->load(":/SimplifiedChinese.qm") ;
        qInfo()<<"是否加载成功"<<ok;
        qApp->installTranslator (trans) ;
        ui->retranslateUi(this); //刷新界面字符串
        QSettings settings("BFSM-Qt", "language Examples") ;
        settings.setValue("Language", "CN") ;
    }

    ui->pushButton->setText(tr("这是一个tr设置文本按钮"));
}


void Widget::on_radioButton_English_clicked(bool checked)
{
    if(checked)
    {
        qApp->removeTranslator(trans) ;
        delete trans ;
        trans=new QTranslator;
        trans->load(":/English.qm") ;
        qApp->installTranslator (trans) ;
        ui->retranslateUi(this); //刷新界面字符串
        QSettings settings("BFSM-Qt", "language Examples") ;
        settings.setValue("Language", "EN") ;
    }

    ui->pushButton->setText(tr("这是一个tr设置文本按钮"));
}

